package com.mx.tool.form.window.zh;

import cn.hutool.core.util.StrUtil;
import org.apache.commons.lang3.StringUtils;

import javax.swing.*;
import java.util.Locale;

/**
 * @Author: 徐建鹏.
 * @create: 2021-11-10 15:04
 * @Description:
 */
public class VarNameWindow {
    private JPanel jPanel;
    private JTextArea contentArea;
    private JTextArea showArea;
    private JButton xtButton;
    private JButton txButton;
    private JButton hhButton;
    private JButton clearButton;
    private JButton upButton;
    private JButton loButton;



    public VarNameWindow() {
        upButton.addActionListener(e -> {
            String content = contentArea.getText();
            if(StringUtils.isNotBlank(content)){
                showArea.setText(content.toUpperCase(Locale.ROOT));
            }
        });
        loButton.addActionListener(e -> {
            String content = contentArea.getText();
            if(StringUtils.isNotBlank(content)){
                showArea.setText(content.toLowerCase(Locale.ROOT));
            }
        });
        xtButton.addActionListener(e -> {
            String content = contentArea.getText();
            if(StringUtils.isNotBlank(content)){
                showArea.setText(StrUtil.toCamelCase(content));
            }
        });
        txButton.addActionListener(e -> {
            String content = contentArea.getText();
            if(StringUtils.isNotBlank(content)){
                showArea.setText(StrUtil.toSymbolCase(content,'_'));
            }
        });
        clearButton.addActionListener(e -> {
            contentArea.setText("");
            showArea.setText("");
        });
        hhButton.addActionListener(e -> {
            String content = contentArea.getText();
            String show = showArea.getText();
            contentArea.setText(show);
            showArea.setText(content);
        });
    }

    public JPanel getContent() {
        return jPanel;
    }
}
